--开服活动
local OpenActExcel = require("excel.openAct")
local CommonDB = require("common.CommonDB")
local Util = require("common.Util")
local LimitMangHeLogic = require("present.LimitMangHeLogic")
local LimitPerpleHeroLogic = require("present.LimitPerpleHeroLogic")

OPEN_ACT_SERVER_GIFT       = 1 -- 开服有礼
OPEN_ACT_KING_WORLD        = 2 -- 战神降临
OPEN_ACT_CHONG_JI          = 3 -- 冲级有礼

OPEN_ACT_DRAW_CARD         = 5 -- 招募豪礼
OPEN_ACT_DRAW_CARD_RANK    = 6 -- 招募排行
OPEN_ACT_SINGLE_CHARGE     = 7 -- 单笔充值
OPEN_ACT_TOTAL_CONSUME     = 8 -- 累计消耗钻石
OPEN_ACT_TOPUP_RANK        = 9 -- 充值排行
OPEN_ACT_TOWER_RANK        = 10-- 爬塔排行

function getOpenActTime(id)
   local openDay = CommonDB.getServerOpenDay()
   if openDay == nil then
	  return false, 0
   end

   local OpenActConfig = OpenActExcel.openAct[id]
   if not OpenActConfig then return false, 0 end

   local sDay = OpenActConfig.sDay;
   local eDay = OpenActConfig.eDay;

   if openDay >= sDay and openDay <= eDay then
      local time = os.time();
   	  local openTime = CommonDB.getServerOpenTime()
      if openTime == 0 then
		 return false, 0
	  end

      local endTime = Util.getDayStartTime(openTime) + eDay * 86400
      return true, endTime - time
   end

   return false, 0
end

function onServerOpenTime()
   LimitMangHeLogic.initAfterHot()
   LimitPerpleHeroLogic.initAfterHot()
end

function initAfterHot()
   LimitMangHeLogic.initAfterHot()
   LimitPerpleHeroLogic.initAfterHot()
end